<!DOCTYPE html>
<!--[if IE 9]>         <html class="no-js lt-ie10" lang="en"> <![endif]-->
<!--[if gt IE 9]><!-->
<html class="no-js" lang="en">
	<!--<![endif]-->

	<head>
		<meta charset="utf-8">

		<title>问卷详情</title>

		<meta name="description" content="AppUI is a Web App Bootstrap Admin Template created by pixelcave and published on Themeforest">
		<meta name="author" content="pixelcave">
		<meta name="robots" content="noindex, nofollow">

		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

		<!-- Icons -->
		<!-- The following icons can be replaced with your own, they are used by desktop and mobile browsers -->
		<link rel="shortcut icon" href="img/favicon.png">
		<link rel="apple-touch-icon" href="img/icon57.png" sizes="57x57">
		<link rel="apple-touch-icon" href="img/icon72.png" sizes="72x72">
		<link rel="apple-touch-icon" href="img/icon76.png" sizes="76x76">
		<link rel="apple-touch-icon" href="img/icon114.png" sizes="114x114">
		<link rel="apple-touch-icon" href="img/icon120.png" sizes="120x120">
		<link rel="apple-touch-icon" href="img/icon144.png" sizes="144x144">
		<link rel="apple-touch-icon" href="img/icon152.png" sizes="152x152">
		<link rel="apple-touch-icon" href="img/icon180.png" sizes="180x180">
		<!-- END Icons -->

		<!-- Stylesheets -->
		<!-- Bootstrap is included in its original form, unaltered -->
		<link rel="stylesheet" href="css/bootstrap.min.css">

		<!-- Related styles of various icon packs and plugins -->
		<link rel="stylesheet" href="css/plugins.css">

		<!-- The main stylesheet of this template. All Bootstrap overwrites are defined in here -->
		<link rel="stylesheet" href="css/main.css">

		<!-- Include a specific file here from css/themes/ folder to alter the default theme of the template -->

		<!-- The themes stylesheet of this template (for using specific theme color in individual elements - must included last) -->
		<link rel="stylesheet" href="css/themes/amethyst.css">
		<!-- END Stylesheets -->

		<!-- Modernizr (browser feature detection library) -->
		<script src="js/vendor/modernizr-3.3.1.min.js"></script>
	</head>

	<body>
		<!-- Page Wrapper -->
		<!-- In the PHP version you can set the following options from inc/config file -->
		<!--
            Available classes:

            'page-loading'      enables page preloader
        -->
		<div id="page-wrapper" class="page-loading">
			<!-- Preloader -->
			<!-- Preloader functionality (initialized in js/app.js) - pageLoading() -->
			<!-- Used only if page preloader enabled from inc/config (PHP version) or the class 'page-loading' is added in #page-wrapper element (HTML version) -->
			<div class="preloader">
				<div class="inner">
					<!-- Animation spinner for all modern browsers -->
					<div class="preloader-spinner themed-background hidden-lt-ie10"></div>

					<!-- Text for IE9 -->
					<h3 class="text-primary visible-lt-ie10"><strong>Loading..</strong></h3>
				</div>
			</div>
			<!-- END Preloader -->

			<!-- Page Container -->
			<!-- In the PHP version you can set the following options from inc/config file -->
			<!--
                Available #page-container classes:

                'sidebar-light'                                 for a light main sidebar (You can add it along with any other class)

                'sidebar-visible-lg-mini'                       main sidebar condensed - Mini Navigation (> 991px)
                'sidebar-visible-lg-full'                       main sidebar full - Full Navigation (> 991px)

                'sidebar-alt-visible-lg'                        alternative sidebar visible by default (> 991px) (You can add it along with any other class)

                'header-fixed-top'                              has to be added only if the class 'navbar-fixed-top' was added on header.navbar
                'header-fixed-bottom'                           has to be added only if the class 'navbar-fixed-bottom' was added on header.navbar

                'fixed-width'                                   for a fixed width layout (can only be used with a static header/main sidebar layout)

                'enable-cookies'                                enables cookies for remembering active color theme when changed from the sidebar links (You can add it along with any other class)
            -->
			<div id="page-container" class="header-fixed-top">

				<!-- Main Container -->
				<div id="main-container">
					<!-- Header -->
					<!-- In the PHP version you can set the following options from inc/config file -->
					<!--
                        Available header.navbar classes:

                        'navbar-default'            for the default light header
                        'navbar-inverse'            for an alternative dark header

                        'navbar-fixed-top'          for a top fixed header (fixed main sidebar with scroll will be auto initialized, functionality can be found in js/app.js - handleSidebar())
                            'header-fixed-top'      has to be added on #page-container only if the class 'navbar-fixed-top' was added

                        'navbar-fixed-bottom'       for a bottom fixed header (fixed main sidebar with scroll will be auto initialized, functionality can be found in js/app.js - handleSidebar()))
                            'header-fixed-bottom'   has to be added on #page-container only if the class 'navbar-fixed-bottom' was added
                    -->
					<header class="navbar navbar-inverse navbar-fixed-top">
						<!-- Left Header Navigation -->
						<ul class="nav navbar-nav-custom">
							<!-- Header Link -->
							<li class="hidden-xs animation-fadeInQuick">
								<a href="questionnaire.html"><big><strong>问道</strong></big></a>
							</li>
							<!-- END Header Link -->
						</ul>
						<!-- END Left Header Navigation -->

						<!-- Right Header Navigation -->
						<ul class="nav navbar-nav-custom pull-right">
							<!-- User Dropdown -->
							<li class="dropdown">
								<span> </span>
								<a onclick="logout()" class="dropdown-toggle" data-toggle="dropdown">
									注销
								</a>
		
								<!-- END User Dropdown -->
						</ul>
						<!-- END Right Header Navigation -->
					</header>
					<!-- END Header -->

					<!-- Page content -->
					<div id="page-content">
						<!-- Blank Header -->
						<div class="content-header">
							<div class="row">
								<div class="col-sm-6">
									<div class="header-section">
										<h1 class="inline">查看问卷</h1>
										<h5 class="inline">-<a href="#modal-chgTitle" data-toggle="modal" id="ques-title-chg">深度国际</a></h5>
									</div>
								</div>
								<div class="col-sm-2 col-sm-offset-4 hidden-xs text-right">
									<div class="header-section">
										<a href="#modal-upload" class="btn btn-lg btn-effect-ripple btn-primary hidden" data-toggle="modal">更新问卷</a>
									</div>
								</div>
							</div>
						</div>
						<!-- END Blank Header -->

						<div class="row">
							<div class="col-sm-8 col-sm-offset-2 col-md-8 col-md-offset-2 col-lg-8 col-lg-offset-2">
								<!-- Get Started Block -->
								<div class="block full">
									<!-- Get Started Content -->
									<!-- 欢迎语 -->
									<h4 id="welcomeTex" class="sub-header text-center"></h4>
									<h1 id="ques-title" class="text-center"></h1>
									<!-- 基本信息部分 -->
									<div id="ques-content">

									</div>
									<!-- END Get Started Content -->
								</div>
								<!-- END Get Started Block -->
							</div>
						</div>

						<!-- upload Modal -->
						<div id="modal-upload" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
							<div class="modal-dialog">
								<div class="modal-content">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
										<h3 class="modal-title"><strong>更新问卷</strong></h3>
									</div>
									<div class="modal-body">
										<form action="localhost:80/questionnaire/upload" enctype="multipart/form-data" class="dropzone"></form>
										<!--<form id="dropz" action="/upload.php" enctype="multipart/form-data">
											<input type="file" name="file" class="dropzone">
										</form>-->
									</div>
									<div class="modal-footer">
										<button type="button" class="btn btn-effect-ripple btn-primary">确定</button>
										<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
									</div>
								</div>
							</div>
						</div>
						<!-- END upload Modal -->
						<!-- chgTitle Modal -->
						<div id="modal-chgTitle" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
							<div class="modal-dialog">
								<div class="modal-content">
									<div class="modal-header">
										<!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>-->
										<h3 class="modal-title"><strong>请输入新的问卷名称</strong></h3>
									</div>
									<div class="modal-body">
										<!--<h4>请输入新的问卷名称</h3>-->
										<input type="text" name="newTitle" id="newTitle" value="" class="form-control" />
										<div id='quesnote' style='margin-left:1%;margin-top:2%;color:red'></div>
									</div>
									<div class="modal-footer">
										<button type="button" class="btn btn-effect-ripple btn-primary" id="btn-chg">确定</button>
										<button type="button" class="btn btn-effect-ripple btn-danger" data-dismiss="modal">取消</button>
									</div>
								</div>
							</div>
						</div>
						<!-- END chgTitle Modal -->
					</div>
					<!-- END Page Content -->
				</div>
				<!-- END Main Container -->
			</div>
			<!-- END Page Container -->
		</div>
		<!-- END Page Wrapper -->

		<!-- jQuery, Bootstrap, jQuery plugins and Custom JS code -->
		<script src="js/vendor/jquery-2.2.4.min.js"></script>
		<script src="js/vendor/bootstrap.min.js"></script>
		<script src="js/plugins.js"></script>
		<script src="js/app.js"></script>
		<script type="text/javascript">
			var id = '',
				text = '';
			var ip,
				getUrl = '/detail';

			$(function() {
				var configJson='js/confing.json'
				$.getJSON(configJson,function(data){
				ip=data.urlip;
				identi()
				getID();
				getDetail();
				});
			});
			
			
			function identi()
			{
				$.ajax({
     				type: "get",
   					url: ip+"/user/type",
  					data:{
  						
  					},
    				async: true,
    				dataType: "json",
     				xhrFields: {withCredentials: true},
    				crossDomain:true,
    				success: function(res) {
    					console.log("sssss")
    					console.log(res)
						if(res.code==-1)
						{
							 window.location.replace("login.html")
							 window.history.forward(1);
						}
    				},
    				async:false
     			});
			}
			function getID() {
				url = location.search;
				if(url.indexOf("?") != -1) { //判断是否有参数
					var str = url.substr(1); //从第一个字符开始 因为第0个是?号 获取所有除问号的所有符串
					strs = str.split("="); //用等号进行分隔 （因为知道只有一个参数 所以直接用等号进分隔 如果有多个参数 要用&号分隔 再用等号进行分隔）
					console.log(strs[1]); //直接弹出第一个参数 （如果有多个参数 还要进行循环的）
					id = strs[1];
				}
			}
			
			function logout(){
			$.ajax({
					type:"get",
					url:ip+"/logout",
					data:{},
					async:true,
					dataType: "json",
					xhrFields: {withCredentials: true},
      				crossDomain:true,
      				success:function(res)
      				{
      					 if(!res.code){
      					 	window.location.href="login.html"
      					 }
      				}
				});	
			}
			
			function getDetail() {
				$.ajax({
					type: "get",
					url: ip + getUrl,
					data: {
						id: id
					},
					dataType: "json",
					//contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						setTitle(res.data[0]);
						text = res.data[1];
						//						console.log(text);
						parseXML(text);
					},
					async: true
				});
			}

			//填充标题
			function setTitle(data) {
				$("#ques-title").html(data);
				$("#ques-title-chg").html(data);
				$("title").html("问卷详情——"+data)
			}

			//以下使用的是jquery框架，简单易学
			//解析xml
			function parseXML(text) {
				//后端获取到的xml
				//				text = "<?xml version=\"1.0\"?><h:html xmlns=\"http://www.w3.org/2002/xforms\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" xmlns:h=\"http://www.w3.org/1999/xhtml\" xmlns:jr=\"http://openrosa.org/javarosa\" xmlns:odk=\"http://www.opendatakit.org/xforms\" xmlns:orx=\"http://openrosa.org/xforms\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><h:head><h:title>questionnaire</h:title><model><instance><questionnaire id=\"questionnaire\"><title/><basic_information><store_name/><store_gps/><collegeType/><sex/><job/></basic_information><survey_question><familiar/><attitude/><right_rate/><efficiency/><overall_evaluation/><advice/></survey_question><meta><instanceID/></meta></questionnaire></instance><bind nodeset=\"/questionnaire/title\" readonly=\"true()\" type=\"string\"/><bind nodeset=\"/questionnaire/basic_information/store_name\" required=\"true()\" type=\"string\"/><bind nodeset=\"/questionnaire/basic_information/store_gps\" required=\"true()\" type=\"geopoint\"/><bind nodeset=\"/questionnaire/basic_information/collegeType\" required=\"true()\" type=\"select1\"/><bind nodeset=\"/questionnaire/basic_information/sex\" required=\"true()\" type=\"select1\"/><bind nodeset=\"/questionnaire/basic_information/job\" required=\"true()\" type=\"select1\"/><bind nodeset=\"/questionnaire/survey_question/familiar\" required=\"true()\" type=\"select1\"/><bind nodeset=\"/questionnaire/survey_question/attitude\" required=\"true()\" type=\"select1\"/><bind nodeset=\"/questionnaire/survey_question/right_rate\" required=\"true()\" type=\"select1\"/><bind nodeset=\"/questionnaire/survey_question/efficiency\" required=\"true()\" type=\"select1\"/><bind nodeset=\"/questionnaire/survey_question/overall_evaluation\" required=\"true()\" type=\"select1\"/><bind nodeset=\"/questionnaire/survey_question/advice\" type=\"string\"/><bind calculate=\"concat('uuid:', uuid())\" nodeset=\"/questionnaire/meta/instanceID\" readonly=\"true()\" type=\"string\"/></model></h:head><h:body><input ref=\"/questionnaire/title\"><label>欢迎使用本系统！</label></input><group ref=\"/questionnaire/basic_information\"><label>基本信息</label><input ref=\"/questionnaire/basic_information/store_name\"><label>what's your name</label></input><input ref=\"/questionnaire/basic_information/store_gps\"><label>collect the GPS</label></input><select1 ref=\"/questionnaire/basic_information/collegeType\"><label>您所在的学院类型？</label><item><label>A.经管类</label><value>economy</value></item><item><label>B.理工类</label><value>science</value></item><item><label>C.文法类</label><value>grammar</value></item></select1><select1 ref=\"/questionnaire/basic_information/sex\"><label>您的性别是？</label><item><label>男</label><value>male</value></item><item><label>女</label><value>female</value></item></select1><select1 ref=\"/questionnaire/basic_information/job\"><label>您的职称？</label><item><label>初级</label><value>primary</value></item><item><label>中级</label><value>middle</value></item><item><label>高级</label><value>high</value></item></select1></group><group ref=\"/questionnaire/survey_question\"><label>调查问题</label><select1 ref=\"/questionnaire/survey_question/familiar\"><label>对该部门的熟悉程度？</label><item><label>熟悉</label><value>familiar_very</value></item><item><label>一般</label><value>familiar_ordinary</value></item><item><label>不熟悉</label><value>familiar_not</value></item></select1><select1 ref=\"/questionnaire/survey_question/attitude\"><label>该部门的服务态度？</label><item><label>非常满意</label><value>attitude_very</value></item><item><label>满意</label><value>attitude_good</value></item><item><label>基本满意</label><value>attitude_oridinary</value></item><item><label>不满意</label><value>attitude_not</value></item><item><label>很不满意</label><value>attitude_verynot</value></item></select1><input ref=\"/questionnaire/survey_question/advice\"><label>你对该部门工作提出的建议</label></input></group></h:body></h:html>";

				//根据不同浏览器解析xml
				try //Internet Explorer
				{
					xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
					xmlDoc.async = "false";
					xmlDoc.loadXML(text);
				} catch(e) {
					try //Firefox, Mozilla, Opera, etc.
					{
						parser = new DOMParser();
						xmlDoc = parser.parseFromString(text, "text/xml");
					} catch(e) {
						alert(e.message);
						return;
					}
				}
				//下面的解析过程的重点：逐节点解析
				//如果不清楚xml的结构可以打印出来
				//使用getElementsByTagName获取xml中的标签部分

				//依次获取h:body节点下的子节点
				//				welcomeTex = xmlDoc.getElementsByTagName("h:body")[0].childNodes[0]; //获取欢迎语
				//				basicInfo = xmlDoc.getElementsByTagName("group")[0]; //xmlDoc.getElementsByTagName("h:body")[0].childNodes[1]; //获取基本信息的填写
				//				content = xmlDoc.getElementsByTagName("group")[1]; //xmlDoc.getElementsByTagName("h:body")[0].childNodes[2]; //获取问卷内容
				//				console.log("====");
				//				console.log(xmlDoc.getElementsByTagName("group")[0]);
				//				console.log(xmlDoc.getElementsByTagName("group")[1]);
				//将欢迎语填充到id为welcomeTex的element中
				//				$("#welcomeTex").html(welcomeTex.getElementsByTagName("label")[0].childNodes[0].nodeValue);
				var group = xmlDoc.getElementsByTagName("group");
				var allHtml = '';
				//生成问卷内容
				for(k = 0; k < group.length; k++) {
					var contentInfo = "";
					x = xmlDoc.getElementsByTagName("group")[k].childNodes;
					console.log(x);
					//遍历问卷内容content的所有子节点
					//每个子节点是一道问题
					for(i = 0; i < x.length; i++) {
						nodeType = x[i].nodeName;
						nodeContent = x[i];
						console.log(nodeType);
						console.log(nodeContent);
						//将节点名称和节点内容传入buildQues生成问题
						//再将返回的每个问题的html字符串连接起来
						contentInfo = contentInfo + buildupQues(nodeType, nodeContent);
					}
					allHtml = allHtml + contentInfo;
				}
				$("#ques-content").html(allHtml);
			}

			//全局变量
			//问题编号计数器
			var count = 1;

			//生成问题
			function buildupQues(type, node) {
				//根据节点名称生成不同的副题目或问题
				switch(type) {
					case 'label':
						var info = buildSubheader(node.childNodes[0].nodeValue);
						break;
					case 'select1':
						var info = buildSingle(node);
						count++;
						break;
					case 'input':
						var info = buildInput(node);
						count++;
						break;
					default:
						var info = '';
						break;
				}
				return info;
			}

			//生成副标题
			function buildSubheader(data) {
				return "<h3 id='ques-subhead'>" + data + "</h3>"
			}

			//生成单选题
			function buildSingle(node) {
				//生成题目的前、后部分
				var front = "<div class='block full'>",
					end = "</div>";
				//生成总选项的前、后部分
				var quesFrontContent = "<div class='form-group' style='font-size: 20px;'><div class='row'><div class='col-md-9' id='form'" + count + ">",
					quesEndContent = "</div></div></div>";
				//生成每个选项的前、后部分
				var frontItem = "<div class='radio'>",
					quesItem = "",
					endItem = "</div>";
				var x = node.childNodes;
				//遍历一个问题的子节点
				for(var j = 0; j < x.length; j++) {
					//第一个子节点为题目
					if(j == 1) {
						console.log("33333");
						console.log(node.childNodes[j].nodeName);
						if(node.childNodes[j].nodeName != '#text') {
							var quesTitle = "<h3>" + count + "." + node.childNodes[j].childNodes[0].nodeValue + "</h3>";
							console.log("0000000000000000");
							console.log(quesTitle)
						}
					}
					//剩余子节点为单选题选项
					else {
						if(node.childNodes[j].nodeName != '#text') {
							console.log("!!!!!!!!!!!!!!!");
							console.log(node.childNodes[j].getElementsByTagName("label")[0].childNodes[0].nodeValue);
							var data = node.childNodes[j].getElementsByTagName("label")[0].childNodes[0].nodeValue;
							var item = "<label class='cssradios cssradios-primary' for='" + data + "'><input type='radio' disabled id='" + data + "' name='example' value='" + data + "'><span></span>" + data + "</label>";
							quesItem = quesItem + frontItem + item + endItem;
						}
					}
				}
				var quesContent = quesFrontContent + quesItem + quesEndContent;
				var ques = front + quesTitle + quesContent + end;
				//返回时生成的html字符串
				return ques;
			}

			//生成填空题
			function buildInput(node) {
				//生成题目的前、后部分
				var front = "<div class='block full'>",
					end = "</div>";
				//生成总选项的前、后部分
				var quesFrontContent = "<div class='form-group' style='font-size: 20px;'><div class='row'><div class='col-md-9' id='form'" + count + ">",
					quesEndContent = "</div></div></div>";
				console.log("------------");
				console.log(node.childNodes[1].childNodes[0].nodeValue);
				var quesTitle = "<h3>" + count + "." + node.childNodes[1].childNodes[0].nodeValue + "</h3>";
				var item = "<textarea type='text' id='example-input' name='example-input' class='form-control'></textarea>";
				var ques = front + quesTitle + quesFrontContent + item + quesEndContent + end;
				//返回时生成的html字符串
				return ques;
			}

			/* 修改问卷名称 */
			$("#btn-chg").on('click', function() {
				if(!$("#newTitle").val()){
						$("#quesnote").html("*输入名称不能为空")
					
				}else{
				$.ajax({
					type: "post",
					url: ip+"/excel/changeName",
					data: {
						id: id,
						name: $("#newTitle").val()
					},
					dataType: "json",
//					contentType: "application/json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res);
						if((!res.code)&&typeof res.data=="string")
						{
							 
								$("#quesnote").html(res.data);
							
						}else{
							location.reload();
						}
					},
					async: true
				});
				}
			});

			/* 更新问卷 */
			var fileArr = new Array();
			var uploadUrl = '/update';
			
			jQuery(function($) {
				Dropzone.autoDiscover = false;
				Dropzone.options.myAwesomeDropzone = false;
				try {
					$(".dropzone").dropzone({
						url: ip + uploadUrl,
						method: "post",
						paramName: "file",
						autoProcessQueue: true, //自动上传
						maxFilesize: 1024, // MB
						uploadMultiple: false,
						parallelUploads: 10,
						acceptedFiles: ".xls,.xlsx",
						dictInvalidFileType: "支持的文件类型是.xls,.xlsx",
						addRemoveLinks: true,
						//    maxFiles：   //指的是上传目录下的最大文件数
						dictRemoveFile: "移除文件",
						dictUploadCanceled: "取消",
						dictCancelUploadConfirmation: "取消上传该文件?",
						dictDefaultMessage: "<span class='bigger-150 bolder'><i class='icon-caret-right red'></i>拖动文件</span>上传\
                <span class='smaller-80 gre'>(或者点击上传)</span> <br /> \
                <i class='upload-icon icon-cloud-upload blue icon-3x'></i>",
						dictResponseError: "文件上传失败!",
						dictFileTooBig: "文件过大,上传失败!",
						//change the previewTemplate to use Bootstrap progress bars
						previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n  <div class=\"dz-details\">\n    <div class=\"dz-filename\"><span data-dz-name></span></div>\n    <div class=\"dz-size\" data-dz-size></div>\n    <img data-dz-thumbnail />\n  </div>\n  <div class=\"progress progress-small progress-striped active\"><div class=\"progress-bar progress-bar-success\" data-dz-uploadprogress></div></div>\n  <div class=\"dz-success-mark\"><span></span></div>\n  <div class=\"dz-error-mark\"><span></span></div>\n  <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>",
						init: function() {
							this.on("addedfile", function(file, data) {
								fileArr.push(file.upload.uuid);
								//解决点击时重复发送请求
								$(".dz-remove").each(function(index) {
									if(!$(".dz-remove:eq(" + index + ")").attr("id")) {
										$(".dz-remove:eq(" + index + ")").attr("id", fileArr[index]);
									}
								})

							})
							this.on("success", function(file, data) {
								var myDropzone = this;
								$("#" + file.upload.uuid).click(function() {
									var fileName = $(this).parent().find(".dz-filename").text();
									if(window.confirm("确定要删除吗?")) {
										$.ajax({
											type: "POST",
											url: "${pageContext.request.contextPath}/uploadController/delete.action",
											data: {
												"fileName": fileName
											},
											//dataType: "json",
											success: function(data) {
												this.removeFile(file);
											}
										})
									}

								})
								

							});
							this.on("sending", function(file, data, formData) {
								//向后台发送该文件的参数
								formData.append('id', id);
							})
							this.on("removedfile", function(file, data) {

							})

							this.on("canceled", function(file, data) {
								// alert("canceled");
								this.removeFile(file);
							});

							this.on("error", function(file, data) {

							});
							this.on("complete", function(file) {
								if(file.status == "canceled" || file.status == "error") {
									var fileName = $("#" + file.upload.uuid).parent().find(".dz-filename").text();
									setTimeout(function() {
										$.ajax({
											type: "POST",
											url: "${pageContext.request.contextPath}/uploadController/delete.action",
											data: {
												"fileName": fileName
											},
											//dataType: "json",
											success: function(data) {
												if(data == "success") {
													// alert("删除成功");
												}
											},
											error: function(ajax) {
												alert(ajax.status);
											}
										})
									}, 2000);
								}
							})

						}
					});
				} catch(e) {
					alert('Dropzone.js does not support older browsers!');
				}

			});
		</script>
	</body>

</html>